package com.graduate.back.controller;


import com.graduate.common.entity.Result;
import com.graduate.common.entity.Users;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author bwzfy
 * @create 2021/5/16
 **/
@Controller
@RequestMapping("/user")
public class UserController extends BaseController {

    @ResponseBody
    @PostMapping("/register")
    public Result<String> register(@RequestBody Users users) {
        // 通过此方法注册的用户为管理员权限
        users.setRole(2);
        boolean save = usersService.save(users);
        if (save) {
            return new Result<String>().success();
        }else {
            return new Result<String>().failure();
        }
    }

}
